package cn.stylefeng.guns.modular.hx.order.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.hx.order.entity.HxOrderOutDetailed;
import cn.stylefeng.guns.modular.hx.order.mapper.HxOrderOutDetailedMapper;
import cn.stylefeng.guns.modular.hx.order.model.params.HxOrderOutDetailedParam;
import cn.stylefeng.guns.modular.hx.order.model.params.HxOrderOutParam;
import cn.stylefeng.guns.modular.hx.order.model.result.HxOrderOutDetailedResult;
import  cn.stylefeng.guns.modular.hx.order.service.HxOrderOutDetailedService;
import cn.stylefeng.guns.modular.hx.storage.model.params.HxStorageStockParam;
import cn.stylefeng.guns.modular.hx.storage.model.result.HxStorageStockResult;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 出库订单明细表 服务实现类
 * </p>
 *
 * @author zhucx
 * @since 2023-08-30
 */
@Service
public class HxOrderOutDetailedServiceImpl extends ServiceImpl<HxOrderOutDetailedMapper, HxOrderOutDetailed> implements HxOrderOutDetailedService {

    @Override
    public void add(HxOrderOutDetailedParam param){
        HxOrderOutDetailed entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(HxOrderOutDetailedParam param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(HxOrderOutDetailedParam param){
        HxOrderOutDetailed oldEntity = getOldEntity(param);
        HxOrderOutDetailed newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    @Override
    public HxOrderOutDetailedResult findBySpec(HxOrderOutDetailedParam param){
        return null;
    }

    @Override
    public List<HxOrderOutDetailedResult> findListBySpec(HxOrderOutDetailedParam param){
        return null;
    }

    @Override
    public LayuiPageInfo findPageBySpec(HxOrderOutDetailedParam param,String condition){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param,condition);
        return LayuiPageFactory.createPageInfo(page);
    }

    private Serializable getKey(HxOrderOutDetailedParam param){
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private HxOrderOutDetailed getOldEntity(HxOrderOutDetailedParam param) {
        return this.getById(getKey(param));
    }

    private HxOrderOutDetailed getEntity(HxOrderOutDetailedParam param) {
        HxOrderOutDetailed entity = new HxOrderOutDetailed();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

	@Override
	public boolean saveBatchList(List<HxOrderOutDetailedParam> list) {
		return this.baseMapper.saveBatchList(list);
	}

	@Override
	public List<HxOrderOutDetailedResult> findSumByOrders(HxOrderOutParam hxOrderOutParam) {
		return this.baseMapper.findSumByOrders(hxOrderOutParam);
	}

	@Override
	public HxStorageStockResult findStockSumBySpec(HxStorageStockParam stockParam) {
		return this.baseMapper.findStockSumBySpec(stockParam);
	}

    @Override
    public List<HxStorageStockResult> findStockSumList(HxStorageStockParam stockParam) {
        return this.baseMapper.findStockSumList(stockParam);
    }


	@Override
	public HxStorageStockResult findStockBySpec(HxStorageStockParam stockParam) {
		return this.baseMapper.findStockBySpec(stockParam);
	}

    @Override
    public List<HxStorageStockResult> findStockListBySpec(HxStorageStockParam stockParam) {
        return this.baseMapper.findStockListBySpec(stockParam);
    }

	@Override
	public void deleteBySpec(HxOrderOutDetailedParam detailedParam) {
		this.baseMapper.deleteBySpec(detailedParam);
	}

	@Override
	public void deletebyorders(List<String> deletedlist) {
		this.baseMapper.deletebyorders(deletedlist);
	}

	@Override
	public List<HxOrderOutDetailedResult> finddtjListBySpec(HxOrderOutDetailedParam detailedParam) {
		return this.baseMapper.finddtjListBySpec(detailedParam);
	}

}
